import {
  get,
  post,
  put,
} from "./base_service"


/**
 * 所有审核相关接口都在这里了
 *
 * allen  2021-08-24
 */

/**
 * 获取报备的管理列表
 * @param {*} page 
 * @param {*} pageSize 
 * @param {*} examineStatus 
 */
const queryRecordManagerList = (page, pageSize, examineStatus, words = "") => {
  return new Promise((resolve, reject) => {
    get("/manager/recommend/list", {
      page: page,
      pageSize: pageSize,
      examineStatus: examineStatus,
      words: words
    }).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 获取报备的管理列表
 * @param {*} page 
 * @param {*} pageSize 
 * @param {*} examineStatus 
 */
const queryCompanyRecordManagerList = (page, pageSize, examineStatus, words = "") => {
  return new Promise((resolve, reject) => {
    get("/manager/recommend/company/list", {
      page: page,
      pageSize: pageSize,
      examineStatus: examineStatus,
      words: words
    }).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 已成功的签约的报备列表
 * @param {*} page 
 * @param {*} pageSize 
 * @param {*} examineStatus 
 */
const queryCompanyCommissionListList = (giveCommissionStatus, page, pageSize, words) => {
  return new Promise((resolve, reject) => {
    get("/manager/recommend/company/commission/setting/list", {
      giveCommissionStatus: giveCommissionStatus,
      page: page,
      pageSize: pageSize,
      words: words
    }).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 管理审核报备
 * @param {*} data 
 */
const checkRecordAction = (data) => {
  return new Promise((resolve, reject) => {
    post("/manager/recommend/check", data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}
/**
 * 公司管理审核报备
 * @param {*} data 
 */
const checkCompanyRecordAction = (data) => {
  return new Promise((resolve, reject) => {
    post("/manager/recommend/company/check", data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * oa的未读数量
 */
const getOANotReadNum = () => {
  return new Promise((resolve, reject) => {
    get("/oa/not/deal/number").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}



/**
 * 报备统计
 * @param {*} startTime 
 * @param {*} endTime 
 */
const queryRecommendStatistics = (startTime, endTime, type) => {
  return new Promise((resolve, reject) => {
    get("/manager/recommend/statistics?startTime=" + startTime + "&endTime=" + endTime + "&type=" + type).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 公司单独的报备统计
 * @param {*} startTime 
 * @param {*} endTime 
 */
const queryCompanyRecommendStatistics = (startTime, endTime, type) => {
  return new Promise((resolve, reject) => {
    get("/manager/recommend/company/statistics?startTime=" + startTime + "&endTime=" + endTime + "&type=" + type).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 查询预约管理页面
 * @param {*} page 
 * @param {*} pageSize 
 * @param {*} status 
 */
const queryBookingManagerList = (page, pageSize, status) => {
  return new Promise((resolve, reject) => {
    get("/manager/booking?page=" + page + "&pageSize=" + pageSize + "&status=" + status).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 预约管理操作，通过或者不通过
 * @param {*} id 
 * @param {*} isPass 
 */
const dealBookingManager = (id, isPass) => {
  return new Promise((resolve, reject) => {
    get("/manager/booking/examine?id=" + id + "&isPass=" + isPass).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 商务管理列表
 * @param {*} page 
 * @param {*} pageSize 
 * @param {*} isDeal 
 */
const bussinessManagerList = (page, pageSize, isDeal) => {
  return new Promise((resolve, reject) => {
    get("/manager/cooperate/list?page=" + page + "&pageSize=" + pageSize + "&isDeal=" + isDeal).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 商务管理处理
 * @param {*} id 
 */
const bussinessManagerDeal = (id) => {
  return new Promise((resolve, reject) => {
    get("/manager/cooperate/deal?id=" + id).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 项目对接人报备管理列表
 * @param {*} page 
 * @param {*} pageSize 
 */
const dockerRecommendList = (page, pageSize, words) => {
  return new Promise((resolve, reject) => {
    get("/manager/recommend/docker/recommend/list?page=" + page + "&pageSize=" + pageSize + "&words=" + words).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}


/**
 * 佣金转账列表
 * @param {*} page 
 * @param {*} pageSize 
 * @param {*} settlementStatus 
 */
const queryCommissionMoneyList = (page, pageSize, settlementStatus, words) => {
  return new Promise((resolve, reject) => {
    get("/manager/recommend/give/commission/list?page=" + page + "&pageSize=" + pageSize + "&settlementStatus=" + settlementStatus + "&words=" + words).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}


/**
 * 分配对接人
 * @param {*} dockerUserId 
 * @param {*} recommendId 
 */
const dockerDistributeAction = (dockerUserId, recommendId) => {
  return new Promise((resolve, reject) => {
    get("/manager/recommend/distribute/docker/user?dockerUserId=" + dockerUserId + "&recommendId=" + recommendId).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}



/**
 * 查询临时公司列表
 **/
const queryTempCompanyList = (words, page, pageSize,) => {
  return new Promise((resolve, reject) => {
    get("/join/temp/company?words=" + words + "&page=" + page + "&pageSize=" + pageSize).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}



/**
 * 公司迁移操作
 **/
const companyTransNewCompany = (oldCompanyNumber, newCompanyNumber) => {
  return new Promise((resolve, reject) => {
    get("/join/migrate/company?oldCompanyNumber=" + oldCompanyNumber + "&newCompanyNumber=" + newCompanyNumber).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}






module.exports = {
  queryRecordManagerList,
  checkRecordAction,
  getOANotReadNum,
  queryRecommendStatistics,
  queryBookingManagerList,
  dealBookingManager,
  bussinessManagerList,
  bussinessManagerDeal,
  dockerRecommendList,
  dockerDistributeAction,
  queryCompanyRecordManagerList,
  checkCompanyRecordAction,
  queryCompanyRecommendStatistics,
  queryCompanyCommissionListList,
  queryCommissionMoneyList,
  queryTempCompanyList,
  companyTransNewCompany
}
